package com.tianming.boot62.mapper;

import com.tianming.boot62.entity.User;
import com.tianming.boot62.entity.Weibo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface WeiboMapper {
    // 数据库中timestamp字段为时间字段，赋值null会设置为当前系统时间
    @Insert("insert into weibo values(null,#{content},#{author},#{url},null,#{userId})")
    void insert(Weibo weibo);

    @Select("select id,content,url,author from weibo order by created desc")
    List<Weibo> select();

    @Select("select id,content,created from weibo where user_id=#{id} order by created desc")
    List<Weibo> selectmyweibo(User user);

    @Delete("delete from weibo where id=#{id}")
    void delete(int id);
}
